<%@page import="com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Model.*"%>
<%@page import="POJO.*"%>
<% 
	ArrayList<ProductPOJO> listproduct;
	String id = (String)request.getParameter("key"); 
	if(id != null)
	{
		listproduct = ProductModel.TimKiem(id);
	}
	else
	{
		listproduct =  ProductModel.DanhSachMatHang();
	}
%>


<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<div id="content">

	<!--  start page-heading -->
	<div id="page-heading">
		<h1>View Products</h1>
	</div>
	<!-- end page-heading -->
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id="content-table-inner">
				 <%if(session.getAttribute("doSuscess")!= null ) { %>
			 <!--  start message-green -->
					<div id="message-green">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="green-left"><%= (String)session.getAttribute("doSuscess")%>.</td>
						<td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
			<!--  end message-green -->
			<%
				session.removeAttribute("doSuscess");
			}
			 else if(session.getAttribute("doError")!= null)
			 {
			%>
				<!--  start message-red -->
					<div id="message-red">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="red-left"><%= (String)session.getAttribute("doError")%>.</td>
						<td class="red-right"><a class="close-red"><img src="images/table/icon_close_red.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
				<!--  end message-red -->
			<%
				session.removeAttribute("doError");
			 }	
			 %> 
			<!--  start table-content  -->
			<div id="table-content">
		 
				<!--  start product-table ..................................................................................... -->
				<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
				<tr>
					<th class="table-header-repeat line-left minwidth-1"><a href="">ID</a>	</th>
					<th class="table-header-repeat line-left minwidth-1"><a href="">Name</a></th>
					<th class="table-header-repeat line-left"><a href="">Price</a></th>
					<th class="table-header-repeat line-left"><a href="">Number</a></th>
					<th class="table-header-repeat line-left"><a href="">Category</a></th>
					<th class="table-header-options line-left"><a href="">Options</a></th>
				</tr>
				<%
					ProductPOJO product=null;
				 	CategoryPOJO cate=null;
					for(int i=0;i< listproduct.size();i++)
					{
						product=listproduct.get(i);
						cate=CategoryModel.SelectCategoryByID(product.GetCategory());
					
				%>
				<tr <% if(i%2 ==0 ) out.write("class='alternate-row'"); %>>
					<td><a href="?id=<%= product.GetID() %>"><%= product.GetID() %></a></td>
					<td><a href="?id=<%= product.GetID() %>"><%= product.GetName() %></a></td>
					<td><a href="?id=<%= product.GetID() %>"><%= product.GetPrice() %></a></td>
					<td><a href="?id=<%= product.GetID() %>"><%= product.GetNumber() %></a></td>
					<td><a href="?id=<%= product.GetID() %>"><%= cate.GetName() %></a></td>
					<td class="options-width">
					<a href="?id=<%= product.GetID() %>" title="Edit" class="icon-1 info-tooltip"></a>
					<form name="delete" method="post" action="product" >
							<input type="hidden" name="id" value="<%= product.GetID() %>">
							<input type="hidden" name="do" value="delete">
							<input type="image"  name="btnSubMit" src="images/table/tran.png"  class="icon-2 info-tooltip" >			
					</form>	
					</td>
				</tr>
				<%} %>
				</table>
				<!--  end product-table................................... --> 
				
			</div>
			<!--  end content-table  -->
		
			
			<div class="clear"></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->